; sidplay.asm
; SID Emu start code - loading & initialisation

	.include "vicrom.inc"

	.import boot
	.importzp ptr

	.import entry
	
	.import __ZEROPAGE_LOAD__
	.import __ZEROPAGE_RUN__
	.import __STACK_LOAD__
	.import __STACK_RUN__
	.import __THIRD_LOAD__
	.import __THIRD_RUN__

	.export hwid
	.export title
	.export author
	.export copyright

	VIC_BASE = $9000
	VIA1_BASE = $9110
	VIA2_BASE = $9120

	IRQ_VECTOR = $0314
	NMI_VECTOR = $0318
	IRQ_TAIL = $EB15
	
	.import __RAM_START__

	.segment "BASIC"

; Startup Basic program "2012 SYS prolog"
			.word	basprg
basprg:		.word	@end
			.word	2012
			.byte	$9E
			.byte	<(prolog / 1000 .mod 10) + $30
			.byte	<(prolog / 100 .mod 10) + $30
			.byte	<(prolog / 10 .mod 10) + $30
			.byte	<(prolog / 1 .mod 10) + $30
			.byte	0
@end:		.word	0

	.segment "BOOT"

prolog:		; print title
			lda #<header
			ldy #>header
			jsr STROUT
			; disable NMI
			lda #$7F				; disable all interrupts
			sta VIA1_BASE+14
			; copy zeropage & other code
			sei
			ldx #0
@zploop:	lda __ZEROPAGE_LOAD__, x
			sta __ZEROPAGE_RUN__, x
			lda __STACK_LOAD__, x
			sta __STACK_RUN__, x
			lda __THIRD_LOAD__, x
			sta __THIRD_RUN__, x
			inx
			bne @zploop
			; start SID Emu
			jmp entry

hwid:		.byte $01 ; PAL (replace $02A6 sidplay)

header:		.byte 13
			.byte "=sid vicious=", 13
			.byte "   (by aleksi eeben)", 13
			.byte "      now playing:", 13, 13
title:		.repeat 22 
			   .byte 32 			
			.endrep
author:		.repeat 22
			   .byte 32 			
			.endrep
copyright:	.repeat 22
			   .byte 32
			.endrep
			.byte 13
footer:		.byte "  brought to you by", 13
			.byte "      kananga's", 13
			.byte "vicious sid converter", 13
			.byte 0
